package com.example.activity_service.controller;


import com.example.activity_service.service.impl.Signinserviceimpl;

import com.example.activity_service.vo.Signin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@CrossOrigin
@ResponseBody
public class SigninController {

    @Autowired
    Signinserviceimpl signinserviceimpl;

    @RequestMapping("/qd")
    public List<Signin> getsign(Signin signin){
        List<Signin> list= signinserviceimpl.query();
        return list;
    }


    @RequestMapping("/sc")
    public int getdelete(@RequestParam("id") int id){
        signinserviceimpl.delete(id);
        return 1;

    }

    @RequestMapping("/xz")
    public boolean getadd(@RequestParam(value = "userid",required =false ) int userid,
                           @RequestParam(value = "datemonth",required = false)Date datemonth,
                           @RequestParam(value = "mask",required = false)int mask,
                           @RequestParam(value = "continuesignmonth",required = false)int continuesignmonth

                           ){
        if (userid  !=1 && datemonth != null){
            signinserviceimpl.add(userid,datemonth,mask,continuesignmonth);
             return true;
        }
          return false ;
    }

    @RequestMapping("/xg")
    public boolean getamend(@RequestParam(value = "userid",required =false ) int userid,
                            @RequestParam(value = "datemonth",required = false)Date datemonth,
                            @RequestParam(value = "mask",required = false)int mask,
                            @RequestParam(value = "continuesignmonth",required = false)int continuesignmonth,
                            @RequestParam(value = "id",required = false) int id

    ){
        signinserviceimpl.amend(id, userid, datemonth, mask, continuesignmonth);
        return true;

    }


}
